package comlib.bundle 

import chisel3._

class Valid[T<:Data](gen:T) extends Bundle {
  val vld = Output(Bool())
  val data = Output(gen)

  override def cloneType = new Valid[T](gen).asInstanceOf[this.type]
}
object Valid{
  def apply[T<:Data]( vld:Bool, data:T ) : Valid[T] = {
    val ret = Wire(new Valid( chiselTypeOf(data) ))
    ret.vld := vld 
    ret.data := data 
    ret
  }
}

class ValidIndex[+T<:Data](gen:T) extends Bundle {

  val value = Output(chiselTypeOf(gen))
  val id = Output(UInt())
  val vld = Output(Bool())

  override def cloneType = new ValidIndex( gen ).asInstanceOf[this.type]
}
